package com.superdry.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.drysurper.R;
import com.superdry.json.OrderListItemBean;
import com.superdry.json.PlaceOrder;

public class OrderInfoActivity extends Activity implements OnClickListener {

	private TextView order_id;
	private TextView order_status;
	private TextView order_time;
	private TextView name;
	private TextView phone;
	private TextView address;
	private TextView post_status;
	private TextView post_time;

	private LinearLayout order_info_goback;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.aty_order_info);
		initViews();
		initDatas();
	}

	/**
	 * 初始化各种view
	 */
	private void initViews() {

		order_id = (TextView) findViewById(R.id.order_id);
		order_status = (TextView) findViewById(R.id.order_status);
		order_time = (TextView) findViewById(R.id.order_time);
		name = (TextView) findViewById(R.id.name);
		phone = (TextView) findViewById(R.id.phone);
		address = (TextView) findViewById(R.id.address);
		post_status = (TextView) findViewById(R.id.post_status);
		post_time = (TextView) findViewById(R.id.post_time);

		order_info_goback = (LinearLayout) findViewById(R.id.order_info_goback);
		order_info_goback.setOnClickListener(this);
	}

	/**
	 * 初始化各种数据
	 */
	private void initDatas() {
		OrderListItemBean item = (OrderListItemBean) getIntent().getSerializableExtra("order_info");
		order_id.setText(item.getOrderID());
		order_status.setText(getOrderStringStatus(item.getOrderStatus()));
		order_time.setText(item.getOrderTime());
		name.setText(item.getPeopleName());
		phone.setText(item.getPhoneNumber());
		address.setText(item.getAddressName());
	}

	/**
	 * 根据orderstatus 获取对应的字符串
	 * 
	 */
	private String getOrderStringStatus(int orderStatus) {
		// 订单状态 0表示为确认 1表示已确认 2表示已取件3表示清洗中 4表示派送中 5表示已完成
		String status = "";
		switch (orderStatus) {
		case 0:
			status = "确认";
			break;
		case 1:
			status = "已确认";
			break;
		case 2:
			status = "已取件";
			break;
		case 3:
			status = "清洗中";
			break;
		case 4:
			status = "派送中";
			break;
		case 5:
			status = "已完成";
			break;

		default:
			status = "信息错误";
			break;
		}

		return status;
	}

	@Override
	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.order_info_goback:
			finish();
			break;

		default:
			break;
		}
	}

}
